/*
 * Copyright 2011 The Rusted Roof, LLC.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package org.proteusframework.platformservice.events;

import java.util.EventObject;

/**
 * Manages a typified set of event listeners wired up to receive a specific type of event.
 *
 * @param <T> Event type produced
 */
public interface IEventProducer<T extends EventObject>
{
    /**
     * Adds a listener to be notified whenever the <code>IEventProducer</code> fires an event of type T (or subtype of T).
     *
     * @param listener <code>IEventConsumer</code> to dispatch the event to
     */
    void addEventListener(IEventConsumer<T> listener);

    /**
     * Removes a listener from the <code>IEventProducer</code>.
     *
     * @param listener <code>IEventConsumer</code> to dispatch the event to
     */
    void removeEventListener(IEventConsumer<T> listener);

    /**
     * Empties out the list of registered <code>IEventConsumer</code>s.
     */
    void clearEventListeners();

    /**
     * Fires a new <code>EventObject</code> into the registered listeners.
     *
     * @param event Event to fire
     */
    void fireEvent(T event);
}